/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sacc.pojos;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Fabio
 */
@Entity
@Table(name = "sacc0004")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Sacc0004.findAll", query = "SELECT s FROM Sacc0004 s"),
    @NamedQuery(name = "Sacc0004.findByIdgrupo", query = "SELECT s FROM Sacc0004 s WHERE s.sacc0004PK.idgrupo = :idgrupo"),
    @NamedQuery(name = "Sacc0004.findByIdpermiso", query = "SELECT s FROM Sacc0004 s WHERE s.sacc0004PK.idpermiso = :idpermiso"),
    @NamedQuery(name = "Sacc0004.findByFechaalta", query = "SELECT s FROM Sacc0004 s WHERE s.fechaalta = :fechaalta")})
public class Sacc0004 implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected Sacc0004PK sacc0004PK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "fechaalta")
    @Temporal(TemporalType.DATE)
    private Date fechaalta;
    @JoinColumn(name = "idpermiso", referencedColumnName = "idpermiso", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Sacc0003 sacc0003;
    @JoinColumn(name = "idgrupo", referencedColumnName = "idgrupo", insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Sacc0002 sacc0002;

    public Sacc0004() {
    }

    public Sacc0004(Sacc0004PK sacc0004PK) {
        this.sacc0004PK = sacc0004PK;
    }

    public Sacc0004(Sacc0004PK sacc0004PK, Date fechaalta) {
        this.sacc0004PK = sacc0004PK;
        this.fechaalta = fechaalta;
    }

    public Sacc0004(int idgrupo, int idpermiso) {
        this.sacc0004PK = new Sacc0004PK(idgrupo, idpermiso);
    }

    public Sacc0004PK getSacc0004PK() {
        return sacc0004PK;
    }

    public void setSacc0004PK(Sacc0004PK sacc0004PK) {
        this.sacc0004PK = sacc0004PK;
    }

    public Date getFechaalta() {
        return fechaalta;
    }

    public void setFechaalta(Date fechaalta) {
        this.fechaalta = fechaalta;
    }

    public Sacc0003 getSacc0003() {
        return sacc0003;
    }

    public void setSacc0003(Sacc0003 sacc0003) {
        this.sacc0003 = sacc0003;
    }

    public Sacc0002 getSacc0002() {
        return sacc0002;
    }

    public void setSacc0002(Sacc0002 sacc0002) {
        this.sacc0002 = sacc0002;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sacc0004PK != null ? sacc0004PK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sacc0004)) {
            return false;
        }
        Sacc0004 other = (Sacc0004) object;
        if ((this.sacc0004PK == null && other.sacc0004PK != null) || (this.sacc0004PK != null && !this.sacc0004PK.equals(other.sacc0004PK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sacc.controlador.util.Sacc0004[ sacc0004PK=" + sacc0004PK + " ]";
    }
    
}
